<?php
	include_once("adb.php");
	
	class subdistrict extends adb{
		function subdistrict(){
			adb::adb();
		}
		/**
		*query all subdistrict in the table and store the dataset in $this->result	
		*@return if successful true else false
		*/
		
		function get_all_subdistrict(){
			$query="select * from subdistrict";
			return $this->query($query);
		}
		
		function add_subdistrict($subdistrict_name, $district_id){
			//write the SQL query and call $this->query()
			$query="insert into subdistrict set subdistrict_name='$subdistrict_name',district_id='$district_id'";
			return $this->query($query);
		}
		/**
		*updates the record identified by id 
		*/
		function update_subdistrict($subdistrict_id, $subdistrict_name, $district_id){
			//write the SQL query and call $this->query()
			$query="update subdistrict set subdistrict_name='$subdistrict_name',district_id='$district_id' where subdistrict_id='$subdistrict_id'";
			return $this->query($query);
		}
		
		function delete_community($subdistrict_id){
			$query="DELETE FROM subdistrict where subdistrict_id='$subdistrict_id'";
			return $this->query($query);
		}
		
		function search_subdistrict($subdistrict_name){
		$query="select * from subdistrict where subdistrict_name='$subdistrict_name'";
			return $this->query($query);
		}
		
		function get_subdistrict($id){
			$query="select * from subdistrict where subdistrict_id=$id";
			if(!$this->query($query)){
				return false;
			}
			return $this->fetch();
		}
		
	}
	
	//call methods here to test
	/*$obj=new community();
	if(!$obj->get_all_community()){
	echo "error";
	}
	$row=$obj->fetch();
	while($row){
	print_r($row);
	$row=$obj->fetch();
	} */
?>